Những câu hỏi liên quan
San San
Xem chi tiết
Nguyễn Trung Hiếu
20 tháng 3 2022 lúc 7:21

Câu 1: 
uses crt;
var s,i,n:integer;
begin clrscr;
s:=0;
write('Nhap n: ');readln(n);
for i:=1 to n do
if i mod 2 <> 0 then inc(s,i);
write('Tong cac so le tu 1 den ',n,' la: ',s);
readln
end.

Bình luận (0)
Nguyễn Trung Hiếu
20 tháng 3 2022 lúc 7:22

Câu 2:
uses crt;
var s,i,n:integer;
begin clrscr;
s:=0;
write('Nhap n: ');readln(n);
for i:=1 to n do
if i mod 2 = 0 then inc(s,i);
write('Tong cac so le tu 1 den ',n,' la: ',s);
readln
end.

Bình luận (0)
Yến Trần Thị Lê
Xem chi tiết
Nguyễn Lê Phước Thịnh
22 tháng 2 2022 lúc 21:38

Câu 2: 

#include <bits/stdc++.h>

using namespace std;

double p1,p2;

int i,n;

int main()

{

cin>>n;

p1=1;

p2=1;

for (i=1; i<=n; i++)

{

if (i%2==0) p2=p2*(i*1.0);

else p1=p1*(i*1.0);

}

cout<<fixed<<setprecision(2)<<p1<<endl;

cout<<fixed<<setprecision(2)<<p2;

return 0;

}

Bình luận (0)
NGUYỄN LÊ XUÂN THỊNH
Xem chi tiết
Nguyễn Lê Phước Thịnh
20 tháng 2 2023 lúc 0:38

Câu 6:

uses crt;

var n,i:integer;

begin

clrscr;

readln(n);

for i:=1 to n do 

if n mod i=0 then write(i:4);

readln;

end.

5:

uses crt;

var n,i,dem:integer;

begin

clrscr;

readln(n);

dem:=0;

for i:=0 to n do

if i mod 2=1 then 

begin

write(i:4);

dem:=dem+1;

end;

writeln;

writeln(dem);

readln;

end.

Bình luận (0)
Ánh sao
Xem chi tiết
Phạm Nguyễn Hồng Anh
28 tháng 2 2021 lúc 16:45

câu 1:

uses crt;

var p,i:integer;

begin

clrscr;

p:=1;i:=1;while i<=5 do

begin

p:=p*i;i:=i+1;

end;

write(p);

readln;

end. 

bai 2:

uses crt;var p,i:integer;begin    clrscr;    p:=1; i:=0;    while i <=10 do    begin

i:=i+1;        if (i mod 2<>0) then p:=p*i;    end;    write(p);    readln;end. bai 3:

uses crt;var n,i,p:integer;begin     clrscr;     write('nhap n: ');     readln(n);     i:=1;     p:=1;     while i<=n do     begin       if i mod 2=0 then p:=p*i;       i:=i+1;     end;     write(p);     readln;end.     

 

Bình luận (3)
Nguyễn Lê Phước Thịnh
28 tháng 2 2021 lúc 19:17

*Cách khác: Dùng for

Câu 1: 

uses crt;

var p,i:longint;

begin

p:=1;

for i:=1 to 4 do 

  p:=p*i;

writeln(p);

readln;

end.

Câu 2: 

uses crt;

var i,s:longint;

begin

clrscr;

s:=1;

for i:=1 to 10 do

  if i mod 2=1 then s:=s*i;

writeln(s);

readln;

end.

Câu 3: 

uses crt;

var n,i,s:longint;

begin

clrscr;

write('Nhap n='); readln(n);

s:=0;

for i:=1 to n do 

  if i mod 2=0 then s:=s+i;

writeln(s);

readln;

end.

Bình luận (1)
Eliette
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:51

Câu 1: 

uses crt;

var a:array[1..100]of integer;

i,n,t,s:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

s:=1;

dem:=0;

for i:=1 to n do 

  if a[i] mod 3=0 then 

begin

inc(dem);

t:=t+a[i];

s:=s*a[i];

end;

if dem=0 then writeln('Khong co so chia het cho 3 trong day')

else begin

writeln('Tong cac so chia het cho 3 la: ',t);

writeln('Tich cac so chia het cho 3 la: ',s);

end;

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:51

Câu 2: 

uses crt;

var a:array[1..100]of integer;

i,n,dem,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

t:=0;

for i:=1 to n do 

 if a[i] mod 2=0 then 

begin

inc(dem);

t:=t+a[i];

end;

writeln('So so chan la: ',dem);

writeln('Tong cac so chan la: ',t);

readln;

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:55

Câu 3: 

uses crt;

var a:array[1..100]of integer;

i,n,dem1,dem2,t1,t2,s1,s2:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

dem1:=0;

dem2:=0;

t1:=0;

t2:=0;

s1:=1;

s2:=1;

for i:=1 to n do

begin

if a[i] mod 2=0 then 

begin

inc(dem1);

t1:=t1+a[i];

s1:=s1*a[i];

end

else begin

inc(dem2);

t2:=t2+a[i];

s2:=s2*a[i];

end;

end;

if dem1=0 then writeln('Khong co so chan trong day')

else begin

writeln('So so chan la: ',dem1);

writeln('Tong cac so chan la: ',t1);

writeln('Tich cac so chan la: ',s1);

end;

if dem2=0 then writeln('Khong co so le trong day')

else begin

writeln('So so le la: ',dem2);

writeln('Tong cac so le la: ',t2);

writeln('Tich cac so le la: ',s2);

end;

readln;

end.

Bình luận (0)
Đạo Thanh
Xem chi tiết
Nguyễn Võ Phương Uyên
Xem chi tiết
Linh lung
Xem chi tiết
Nguyễn Lê Phước Thịnh
16 tháng 1 2022 lúc 22:25

#include <bits/stdc++.h>

using namespace std;

long long i,n,s;

int main()

{

cin>>n;

s=0;

for (i=1; i<=n; i++)

if (i%2==0) s=s+i;

cout<<s;

return 0;
}

Bình luận (0)
Nguyễn Đặng Hà Phương
Xem chi tiết